<?php

namespace app\index\controller;

use app\common\CommonController;

class Commonapi extends CommonController
{
    //异步导出统一处理入口
    public function exportAsync()
    {
        ignore_user_abort(true);
        set_time_limit(3600);
        ini_set('memory_limit', '2048M');
        $param =$this->param;
        $param['down'] = 1;
        if (isset($param['export_id'])) {
            // 设置为处理中
            \app\index\model\ImportexportModel::dbUpdateImportexport($param['export_id'],['state'=>2]);
            call_user_func($param['actionAsync'], $param);
            returnJson();
        } else {
            trace('export_id不能为空','error');
        }
    }
    //异步导入统一处理入口
    public function importAsync()
    {
        ignore_user_abort(true);
        set_time_limit(3600);
        ini_set('memory_limit', '2048M');
        $param =$this->param;
        // 设置为处理中
        \app\index\model\ImportexportModel::dbUpdateImportexport($param['importId'],['state'=>2]);
        call_user_func("app\common\service\ExcelLibraryService::read", $param);
        returnJson();
    }
}
